using Single.Core.Service;
using Single.Sugar.Service;
using Single.Sys.Entity;
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Collections.Generic;
using System.Text;

namespace Single.Sys.Service
{
    public class SysRegionService : BaseService<SysRegion>
    {
        public List<SysRegion> GetTreeData()
        {
            var list = rep.AsQueryable().Where(m => m.Type != "street").ToList();

            List<SysRegion> SetNode(long pid)
            {
                var nodes = list.Where(m => m.Pid == pid).ToList();

                nodes.ForEach(m => m.Children = SetNode(m.Id));

                return nodes;
            }

            return SetNode(0);
        }
    }
}